package me.dev.demo;

import com.alibaba.druid.filter.stat.StatFilter;
import com.alibaba.druid.util.JdbcConstants;
import com.alibaba.druid.wall.WallFilter;
import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;

/******************************************************************************
 * 北京易华录信息技术股份有限公司
 * ----------------------------------------------------------------------------
 * 模块名称:模块名称
 * 类 名 称:me.dev.demo.DemoConfig
 * 版　　本:Version 1.0
 * <p/>
 * 作 成 日:12/3/2015   Version 1.0   作　成　者:Liuwx
 * 最终更新:12/3/2015   Version 1.0   最终更新者:Liuwx
 * ----------------------------------------------------------------------------
 * 更新履历:
 * 12/3/2015   Version.1.0   初版作成者:Liuwx
 ******************************************************************************/

public class DemoConfig extends JFinalConfig {
    public void configConstant(Constants me) {
        me.setEncoding("utf-8");
        me.setI18nDefaultBaseName("i18n.messages");
        me.setDevMode(true);
        me.setViewType(ViewType.JSP);
    }

    public void configRoute(Routes me) {
        me.add("/", HelloController.class);
    }

    public void configPlugin(Plugins me) {
        DruidPlugin dp = new DruidPlugin("jdbc:mysql://localhost/monkey", "root", "!admin@2016",
                JdbcConstants.MYSQL_DRIVER);
        me.add(dp);
        dp.addFilter(new StatFilter());
        WallFilter wall = new WallFilter();
        wall.setDbType(JdbcConstants.MYSQL);
        dp.addFilter(wall);
        me.add(dp);
        ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
        me.add(arp);
        arp.addMapping("user", User.class);
    }

    public void configInterceptor(Interceptors me) {
    }

    public void configHandler(Handlers me) {
    }
}

